﻿package 
{
    import ChatMcBox.*;
    import flash.events.*;

    public class ChatMcBox extends McBoxBase
    {
        private var _mcData:Object;
        private var _isPitch:Boolean = false;
        private var _boxId:int = 0;
        private var _onSendData:Function;

        public function ChatMcBox()
        {
            this._onSendData = new Function();
            this._Name.mouseEnabled = false;
            this._Back.addEventListener(MouseEvent.CLICK, this.backClick);
            this._Back.addEventListener(MouseEvent.MOUSE_OVER, this.backOver);
            this._Back.addEventListener(MouseEvent.MOUSE_OUT, this.backOut);
            return;
        }// end function

        public function set mcData(param1:Object) : void
        {
            this._mcData = param1;
            return;
        }// end function

        public function set isPitch(param1:Boolean) : void
        {
            this._isPitch = param1;
            this._Back.gotoAndStop(1);
            return;
        }// end function

        public function set boxId(param1:int) : void
        {
            this._boxId = param1;
            return;
        }// end function

        public function set htmlText(param1:String) : void
        {
            this._Name.htmlText = param1;
            return;
        }// end function

        public function set mcWidth(param1:int) : void
        {
            this._Back.width = param1;
            this._Name.width = param1;
            return;
        }// end function

        public function set mcHeight(param1:int) : void
        {
            this._Back.height = param1;
            this._Name.height = param1;
            return;
        }// end function

        public function set onSendData(param1:Function) : void
        {
            this._onSendData = param1;
            return;
        }// end function

        public function set text(param1:String) : void
        {
            this._Name.htmlText = param1;
            return;
        }// end function

        public function clear() : void
        {
            this._mcData = null;
            this._Back.mouseEnabled = false;
            this._Name.mouseEnabled = false;
            this._Back.removeEventListener(MouseEvent.CLICK, this.backClick);
            this._Back.removeEventListener(MouseEvent.MOUSE_OVER, this.backOver);
            this._Back.removeEventListener(MouseEvent.MOUSE_OUT, this.backOut);
            return;
        }// end function

        private function backOver(event:MouseEvent) : void
        {
            this._Back.gotoAndStop(2);
            return;
        }// end function

        private function backOut(event:MouseEvent) : void
        {
            if (this._isPitch)
            {
                return;
            }
            this._Back.gotoAndStop(1);
            return;
        }// end function

        private function backClick(event:MouseEvent) : void
        {
            if (this._isPitch)
            {
                return;
            }
            this._isPitch = true;
            if (this._mcData)
            {
                this._onSendData(this._mcData, this._boxId);
            }
            return;
        }// end function

    }
}
